package com.simplerobot.robot.tieba;

import com.simplerobot.robot.Spider;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.model.OOSpider;

/**
 * Created by liangcq on 2017/3/29.
 */
public class BaiduTieBaSpider extends Spider {

    @Override
    public void run() {
        BaiduTieBaSpider baiduTieBaSpider= this;
        new Thread(new Runnable() {
            @Override
            public void run() {
                OOSpider ooSpider = OOSpider.create(Site.me().setRetrySleepTime(2).setSleepTime(500).setCharset("utf-8")
                        , new TieBaPageModelPipeLine(baiduTieBaSpider,getPageConsume()), TieBa.class);
                ooSpider.addUrl(getUrl())
                        .thread(getThreadNumber())
                        .run();
            }
        }).start();


    }

    @Override
    public void stop() {

    }
}
